#include <queue>
#include <iostream>

char maze[35][35];
bool vitesd[35][35];

using namespace std;

int main()
{
    int next[4][2] = { {0,1},{1,0},{-1,0},{0,-1} };
    int m, n;
    cin >> n >> m;
    queue<vector<int>> q;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> maze[i][j];
            if (maze[i][j] == 'k')
            {
                q.push({ i,j,1 });
                maze[i][j] = '*';
            }
        }
    }

    int ans = 0x3f3f3f3f;
    int cnt = 0;


    while (!q.empty())
    {
        int x = q.front()[0];
        int y = q.front()[1];
        int step = q.front()[2];
        q.pop();
        for (auto& e : next)
        {
            int nextx = x + e[0], nexty = y + e[1];

            if (nextx<1 || nexty<1 || nextx>n || nexty>m || maze[nextx][nexty] == '*') continue;

            if (maze[nextx][nexty] == 'e')
            {
                cnt++;
                ans = min(ans, step);
                maze[nextx][nexty] = '*';
                continue;
            }
            q.push({ nextx,nexty,step + 1 });
            maze[nextx][nexty] = '*';
        }
    }

    if (cnt == 0)
    {
        cout << -1 << endl;
    }
    else cout << (cnt == 0 ? -1 : cnt) << ' ' << (ans == 0x3f3f3f3f ? 0 : ans) << endl;

    return 0;
}